#include "../RollerInstructionView/rollerinstructionview.h"
#include "rollerinstructiondelegate.h"

RollerInstructionDelegate::RollerInstructionDelegate(QWidget *parent)
    : QWidget(parent)
{
}

void RollerInstructionDelegate::initView()
{
    rollerInstructionView->instructionStr = "ROLLER";
    rollerInstructionView->timeOutValue = 1;
    rollerInstructionView->jmpLbValue = 1;
    rollerInstructionView->noteStr = "";
    rollerInstructionView->rollerDirectionType = E_ROLLER_LEFT_LOAD;
//    rollerInstructionView->rollerType = E_ROLLER_GENERAL;
}

void RollerInstructionDelegate::finishedEditInstructionSlot()
{
    rollerInstructionView->instructionStr = QObject::tr("ROLLER ");
    rollerInstructionView->instructionStr += QObject::tr("General,");
//    if(rollerInstructionView->rollerType == E_ROLLER_GENERAL)
//    {

//    }
//    else if(rollerInstructionView->rollerType == E_ROLLER_HEAVY)
//    {
//        rollerInstructionView->instructionStr += QObject::tr("Heavy,");
//    }

    if(rollerInstructionView->rollerDirectionType == E_ROLLER_LEFT_LOAD)
    {
        rollerInstructionView->instructionStr += QObject::tr("P,");
    }
    else if(rollerInstructionView->rollerDirectionType == E_ROLLER_LEFT_DOWNLOAD)
    {
        rollerInstructionView->instructionStr += QObject::tr("R,");
    }
    else  if(rollerInstructionView->rollerDirectionType == E_ROLLER_RIGHT_LOAD)
    {
        rollerInstructionView->instructionStr += QObject::tr("A,");
    }
    else if(rollerInstructionView->rollerDirectionType == E_ROLLER_RIGHT_DOWNLOAD)
    {
        rollerInstructionView->instructionStr += QObject::tr("B,");
    }

    rollerInstructionView->instructionStr += QString::number(rollerInstructionView->timeOutValue) + \
            QObject::tr(",JMP LB[") + QString::number(rollerInstructionView->jmpLbValue) + "]";
    rollerInstructionView->instructionStr += QObject::tr("   //") + rollerInstructionView->noteStr;

}

void RollerInstructionDelegate::cleanNoteSlot()
{
    rollerInstructionView->noteStr.clear();
}

